#include "stdafx.h"
#include "TreeExample.h"

void TreeExample::loadFile(const String& fileName, FCView *view){
    FCUIXml::loadFile(fileName, view);
    FCTree *tree = getTree(L"Tree");
   //获取第二页
   FCTabPage *tabPage = getTabPage(L"TabPage2");
   FCTree *newTree = new FCTree();
    FCPoint point = {50, 50};
   newTree->setLocation(point);
    FCSize size = {200, 400};
   newTree->setSize(size);
   newTree->setHeaderVisible(false);
   tabPage->addView(newTree);

   for (int i = 0; i < 10; i++)
   {
       FCGridColumn *column1 = new FCGridColumn();
       column1->setWidth(20);
       newTree->addColumn(column1);
       FCGridColumn *column2 = new FCGridColumn();
       column2->setWidth(20);
       newTree->addColumn(column2);
       FCGridColumn *column3 = new FCGridColumn();
       column3->setWidth(160);
       newTree->addColumn(column3);
   }
   newTree->update();

   for (int i = 0; i < 3; i++)
   {
       FCTreeNode *node =  new FCTreeNode();
       node->setText(L"Node");
       newTree->appendNode(node);
       for (int j = 0; j < 3; j++)
       {
           FCTreeNode *subNode = new FCTreeNode();
           subNode->setText(L"SubNode");
           node->appendNode(subNode);
           for (int m = 0; m < 3; m++)
           {
               FCTreeNode *sunNode = new FCTreeNode();
               sunNode->setText(L"SunNode");
               subNode->appendNode(sunNode);
           }
       }
   }
   newTree->update();
}
